/**
 * 
 */
package com.pi.thread;

import java.io.IOException;
import org.springframework.core.task.TaskExecutor;

import com.pi.parser.GDGpsDataParser;


/**
 * @author HXX
 * 
 */
public class TaskExecutorWork {

	private TaskExecutor taskExecutor;
	private String path;
	private String outfileName;

	public TaskExecutorWork() {
	}

	public TaskExecutorWork(TaskExecutor taskExecutor) {
		this.taskExecutor = taskExecutor;
	}

	public void start() {
		taskExecutor.execute(new ParseFileTread(path,outfileName));
	}

	private class ParseFileTread implements Runnable {

		private String path;
		private String outfileName;

		public ParseFileTread(String path,String outfileName) {
			this.path = path;
			this.outfileName = outfileName;
		}

		@Override
		public void run() {
			
			try {
				System.out.println("线程启动");
				parseFile();
				System.out.println("线程结束");
			} catch (Exception e) {
				e.printStackTrace();
			}	
		}

		private void parseFile() throws IOException {

			GDGpsDataParser parser = new GDGpsDataParser();
			try {
				parser.parseFile(path,outfileName);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public void setOutfileName(String outfileName) {
		this.outfileName = outfileName;
	}

	public String getOutfileName() {
		return outfileName;
	}

}
